package com.xinhe.cn.cpbox.controller;

import com.xinhe.cn.cpbox.entity.po.MatchMaker;
import com.xinhe.cn.cpbox.service.MoonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author HB
 * @date 2021/10/09 11:31
 */
@Api(value = "H5端支付接口", tags = {"H5端支付接口"})
@RestController
@RequestMapping("/moon")
public class MoonController {
    @Autowired
    MoonService moonService;

    @ApiOperation(value = "根据openid查询月老信息接口", notes = "根据openid查询月老信息接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "matchMakerId", value = "要查询的openId", dataTypeClass = String.class)
    })
    @GetMapping("/findMatchMakerInfo")
    public Object findMatchMakerInfo(@RequestParam("matchMakerId") String matchMakerId) {
        return moonService.findMatchMakerInfo(matchMakerId);
    }

    @ApiOperation(value = "查询客服二维码图片", notes = "查询客服二维码图片")
    @GetMapping("/getServiceQrCode")
    public Object getServiceQrCode() {
        return moonService.getServiceQrCode();
    }

    @ApiOperation(value = "发起提现请求", notes = "发起提现请求")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "matchMakerId", value = "提现人的openId", dataTypeClass = String.class),
            @ApiImplicitParam(name = "needMoney", value = "需要提现的金额，最多两位小数", dataTypeClass = String.class),
            @ApiImplicitParam(name = "qrCode", value = "上传对象桶得到的收款二维码url", dataTypeClass = String.class),
            @ApiImplicitParam(name = "realName", value = "收款账户姓名", dataTypeClass = String.class),
            @ApiImplicitParam(name = "contactWechat", value = "联系用微信号", dataTypeClass = String.class)
    })
    @PostMapping("/sendCashOutApply")
    public Object sendCashOutApply(@ApiIgnore @RequestBody MatchMaker matchMaker) {
        return moonService.sendCashOutApply(matchMaker);
    }

    @ApiOperation(value = "分页查询下级/下下级月老", notes = "分页查询下级/下下级月老")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "matchMakerId", value = "要查询的人的openId", dataTypeClass = String.class),
            @ApiImplicitParam(name = "type", value = "数字，传1查询下级月老，传2查询下下级月老", dataTypeClass = String.class),
            @ApiImplicitParam(name = "page", value = "页码，从1开始", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "size", value = "每页个数", dataTypeClass = Integer.class)
    })
    @GetMapping("/getMyChilds")
    public Object getMyChilds(@RequestParam("matchMakerId") String matchMakerId,
                              @RequestParam("type") int type,
                              @RequestParam("page") int page,
                              @RequestParam("size") int size) {
        return moonService.getMyChilds(matchMakerId, type, page, size);
    }

    @ApiOperation(value = "分页查询下级/下下级月老", notes = "分页查询下级/下下级月老")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "openId", value = "要查询的人的openId", dataTypeClass = String.class),
            @ApiImplicitParam(name = "page", value = "页码，从1开始", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "size", value = "每页个数", dataTypeClass = Integer.class)
    })
    @GetMapping("/getUserRecord")
    public Object getUserRecord(@RequestParam("openId") String openId,
                              @RequestParam("page") int page,
                              @RequestParam("size") int size) {
        return moonService.getUserRecord(openId, page, size);
    }
}
